package com.shop2cn.iapi.couponmanage.service;

import java.util.List;

import org.json.JSONObject;

import com.google.common.reflect.TypeToken;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.shop2cn.iapi.couponmanage.parameter.batchinfo3;
import com.shop2cn.iapi.couponmanage.parameter.old.BatchInfo;
import com.ymt.base.YmatouBaseCall;
import com.ymt.core.tool.FormatUtil;
import com.ymttest.utils.DataUtil;
import com.ymttest.utils.EnvSetup;
/**
*获取批次信息接口Call
*FreeMaker Template自动生成代码
*/
public class GetBatchInfoCall extends YmatouBaseCall{
	private static String opurl ="api/PlatformManage/GetBatchInfo";
	
	public GetBatchInfoCall() {
		super(EnvSetup.getSystemUrl("couponmanage_shop2cn_iapi"),opurl,"POST","JSON");
	}
	@Override
	public void addDefHeader() {
		client.addHeader("Accept","text/xml,text/javascript,text/html,application/json");
		client.addHeader("Content-Type", "application/json; charset=UTF-8");
	}
	
	/**
	 * 获取Code
	 * 
	 * @return
	 */
	public String getCode() {
		return getString("statusCode");		
	}

	/**
	 * 获取Message
	 * 
	 * @return
	 */
	public String getMessage() {
		return getString("message");	
	}

	/**
	 * 获取Data
	 * 
	 * @return
	 */
	public String getData() {
		return getString("data");	
	}

	public BatchInfo getBatchInfo()
	{
		BatchInfo data = null;
        try {
           // data = (BatchInfo) FormatUtil.GSONToObject(new JSONObject(getData()).getString("batchInfo"), BatchInfo.class);

            Gson gson = new GsonBuilder().setDateFormat("yyyy-MM-dd'T'HH:mm:ss").create();
        	data=  gson.fromJson(getJsonObject().get("data").getAsJsonObject().get("batchInfo").getAsJsonObject(), new TypeToken<BatchInfo>() {}.getType());
        	  
        } catch (Exception e) {
            e.printStackTrace();
        }
        return data;
	}
}